<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>蓝莲花 | 会员登陆</title>
<link type="text/css" rel="stylesheet" href="@{'/public/indexFile/css/public.css'}" charset="utf-8"/>
<link type="text/css" rel="stylesheet" href="@{'/public/indexFile/css/index.css'}" charset="utf-8"/>
<link rel="shortcut icon" type="image/png" href="@{'/public/images/favicon.png'}"/>
<script type="text/javascript" language="javascript" src="@{'/public/indexFile/js/index.js'}" charset="utf-8"></script>
<link rel="stylesheet" href="/public/stylesheets/alert.css" type="text/css" />
<script type="text/javascript" src="/public/javascripts/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="/public/javascripts/adu.alert.js"></script>
<style type="text/css">
	.code{
	background-image:url(code.jpg);
	font-family:Arial;
	font-style:italic;
	color:Red;
	border:0;
	padding:2px 3px;
	letter-spacing:3px;
	font-weight:bolder;
	}
	.unchanged {
	border:0;
}
</style>
</head>

<body onload="createCode();" >
	<div class="meml">
    	<div class="he_a">
        	<div class="he_a1">
                #{if user}
				<ul>
                	<li>欢迎来到微微书香！</li>
                    <li class="hv">${user.memname }</li>
                    <li><a href="/controllers/MemberView.logout">退出</a></li>
                </ul>
				#{/if}
				#{else}
				<ul>
                	<li>欢迎来到微微书香！</li>
                    <li class="hv">您还未登录</li>
                    <li><a href="/controllers/MemberView.log">登录</a></li>
                </ul>
				#{/else}
            </div>
            <div class="he_a2">
            	<ul>
                    <li class="ha2"><a href="#">提醒</a></li>
                    <li><a href="#">还书</a></li>
                    <li><a href="/controllers/Order.bookList">借阅车</a></li>
                    <li><a href="#">我的借阅卡</a></li>
                    <li><a href="#">我的书房</a></li>
                    <li><a href="#">新手上路</a></li>
                </ul>
            </div>
        </div>
        <div class="he_b">
        	<div class="he_b1"><a href="/"><img src="@{'/public/indexFile/images/memg_02.gif'}"/></a></div>
        </div>
        <div class="mem1_a">
        	<div class="m1_a_1">
            	<div class="my_a">
                	<div class="my_a1">
                    	<div class="mya_a">
                        	<div class="mya_a1"></div>
                            <div class="mya_a2">还不是本站用户？</div>
                            <div class="mya_a3"><a href="registere.html"><img src="@{'/public/indexFile/images/memg_04.gif'}"/></a></div>
                        </div>
                        <div class="mya_b">
                        	<div class="mya_b1">Email</div>
                            <div class="mya_b2"><input id="uname" type="text"/></div>
                        </div>
                        <div class="myu"></div>
                        <div class="mya_c">
                        	<div class="mya_b1">密&nbsp;&nbsp;码</div>
                            <div class="mya_b2"><input id="upwd" type="password"/></div>
                            <a href="/forgetpwd.html">忘记密码？</a>
                        </div>
                        <div class="myu"></div>
                        <div class="mya_d">
                        	<div class="mya_d1">验证码</div>
                            <div class="mya_d2"><input id="input1" type="text"/></div>
                            <div class="mya_d3"><input type="text" readonly="true"  id="checkCode" class="code" style="width: 120px;height:25px;text-align:center;" /></div>
                            <a onclick="createCode();" href="#">换张图</a>
                        </div>
                        <div class="mya_e"><a id="sub" href="javascript:void(0);"><img src="@{'/public/indexFile/images/memg_06.gif'}"/></a></div>
                    </div>
                </div>
            </div>
        </div>
        <div class="mem1_b">
        	<ul>
            	<li>COPYRIGHT © 2001-2010 互联在线 ALL RIGHTS RESERVED 站长统计</li>
                <li>信息产业部增值许可证： 粤B1.B2-20080198 广电经营许可证号：(粤)字第577号</li>
                <li>双软编号： DGY-2009-2004 粤ICP备09100335号</li>
            </ul>
        </div>
    </div>
    	<script type="text/javascript">
	   		var code ; //在全局 定义验证码
			function createCode(){
				code = "";
				var codeLength = 4;//验证码的长度
				var checkCode = document.getElementById("checkCode");
				checkCode.value = "";
				
				var selectChar = new Array(2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','J','K','L','M','N','P','Q','R','S','T','U','V','W','X','Y','Z');
				
				for(var i=0;i<codeLength;i++) {
				   var charIndex = Math.floor(Math.random()*32);
				   code +=selectChar[charIndex];
				}
				if(code.length != codeLength){
				   createCode();
				}
				checkCode.value = code;
			}
			
	   		$("#sub").click(function(){
	   			var uname = $("#uname").val();
	   			var upwd = $("#upwd").val(); 
	   			
	   			if(uname == "" || upwd == ""){
	   				aduAlert("用户名/密码不能为空！","提示");
	   				return false;
	   			}
	   			
	   			var inputCode = document.getElementById("input1").value.toUpperCase();
				
				if(inputCode.length <=0) {
				   aduAlert("请输入验证码！","提示");
				   return false;
				}
				else if(inputCode != code ){
				   aduAlert("验证码输入错误！","提示");
				   createCode();
				   return false;
				}else{
					$.ajax({
		   				type:'post',
		   				url :'/controllers/MemberView.login',
		   				dataType:'html',
		   				data:({'uname':$("#uname").val(),'upwd':$("#upwd").val()}),
		   				success:function(e){
		   					if(e == "1"){
		   						window.location.href="member.html";
		   					}
		   					if(e == "0"){
		   						aduAlert("密码/用户不匹配！","提示",function(){
		   							createCode();
		   						});
		   					}
		   				}
		   			});
		   			return true;
				}
	   		});
	   		
	   		document.onkeydown=function(event)
			{
				e = event ? event :(window.event ? window.event : null);
			if(e.keyCode==13){
				//执行的方法
				var uname = $("#uname").val();
	   			var upwd = $("#upwd").val(); 
	   			
	   			if(uname == "" || upwd == ""){
	   				aduAlert("用户名/密码不能为空！","提示");
	   				return false;
	   			}
	   			
	   			var inputCode = document.getElementById("input1").value.toUpperCase();
				
				if(inputCode.length <=0) {
				   aduAlert("请输入验证码！","提示");
				   return false;
				}
				else if(inputCode != code ){
				   aduAlert("验证码输入错误！","提示");
				   createCode();
				   return false;
				}else{
					$.ajax({
		   				type:'post',
		   				url :'/controllers/MemberView.login',
		   				dataType:'html',
		   				data:({'uname':$("#uname").val(),'upwd':$("#upwd").val()}),
		   				success:function(e){
		   					if(e == "1"){
		   						window.location.href="member.html";
		   					}
		   					if(e == "0"){
		   						aduAlert("密码/用户不匹配！","提示",function(){
		   							createCode();
		   						});
		   					}
		   				}
		   			});
		   			return true;
				}
			}
			}
	   	</script>
</body>
</html>
